<template>
  <div class="search">
    <Card>
      <Row @keydown.enter.native="handleSearch">
        <Form
          ref="searchForm"
          :model="searchForm"
          inline
          :label-width="70"
          class="search-form"
        >
          <FormItem label="登录账号" prop="companyPhone">
            <Input
              type="text"
              v-model="searchForm.companyPhone"
              placeholder="请输入手机号"
              clearable
              style="width: 180px"
            />
          </FormItem>
          <FormItem label="公司名称" prop="companyName">
            <Input
              type="text"
              v-model="searchForm.companyName"
              placeholder="请输入公司名称"
              clearable
              style="width: 180px"
            />
          </FormItem>
          <FormItem label="认证状态">
            <Select
              placeholder="请选择认证状态"
              v-model="searchForm.registStatus"
              style="width: 180px"
            >
              <Option value="">全部</Option>
              <Option value="0">未认证</Option>
              <Option value="1">已认证</Option>
              <Option value="2">待审核</Option>
            </Select>
          </FormItem>
          <span style="margin-left: 35px" class="br">
            <Button @click="handleSearch" type="primary" icon="ios-search"
              >搜索</Button
            >

            <Button @click="handleReset">重置</Button>
            <Button @click="getDataList" icon="md-refresh">刷新</Button>
            <Button @click="addCargOwner" lang="" type="primary" icon="md-add"
              >新增货主</Button
            >
          </span>
        </Form>
      </Row>
      <Row>
        <Table
          :loading="loading"
          border
          :columns="columns"
          :data="data"
          ref="table"
          sortable="custom"
          @on-sort-change="changeSort"
          @on-selection-change="changeSelect"
        >
          <template slot-scope="{ row }" slot="action">
            <div style="display: flex">
              <div>
                <span style="color: #2d8cf0; cursor: pointer" @click="edit(row)"
                  >查看
                </span>
              </div>
              <div>
                <Dropdown transfer trigger="click" style="margin-left: 20px">
                  <a href="javascript:void(0)" style="display: inline-block">
                    更多
                    <Icon type="ios-arrow-down"></Icon>
                  </a>
                  <DropdownMenu slot="list" class="more-css">
                    <DropdownItem
                      style="color: red"
                      v-if="row.status == 0"
                      @click.native="frozen(row)"
                      >禁用</DropdownItem
                    >
                    <DropdownItem
                      @click.native="Enable(row)"
                      v-if="row.status == -1"
                      >启用</DropdownItem
                    >
                    <DropdownItem @click.native="operationRecordClick(row)"
                      >操作记录</DropdownItem
                    >
                  </DropdownMenu>
                </Dropdown>
              </div>
            </div>
          </template>
        </Table>
      </Row>
      <Row type="flex" justify="end" class="page">
        <Page
          transfer
          :current="searchForm.pageNumber"
          :total="total"
          :page-size="searchForm.pageSize"
          @on-change="changePage"
          @on-page-size-change="changePageSize"
          :page-size-opts="[10, 20, 50]"
          size="small"
          show-total
          show-elevator
          show-sizer
        ></Page>
      </Row>
    </Card>
    <!-- 签约弹框 -->
    <Modal
      v-model="modalNotSigned"
      title="企业签约"
      width="720"
      :styles="{ top: '100px' }"
    >
      <div style="display: flex">
        <div class="SignedModalcss">
          <div class="SigneContractC">
            <div class="SignedUpload">
              <div slot="label" class="checkdrag"></div>
              <div style="width: 223px; margin-left: 10px">
                <Upload
                  type="drag"
                  action="#"
                  :headers="header"
                  :format="['pdf', 'PDF']"
                  :on-success="sendSuccess"
                  :before-upload="ContractCarriageUpload"
                >
                  <div style="padding: 1px 0">
                    <Icon
                      type="ios-cloud-upload"
                      size="10"
                      style="color: #3399ff"
                    ></Icon>
                    <p style="font-size: 12px">上传合同(PDF格式)</p>
                  </div>
                </Upload>
              </div>
            </div>
            <div class="ContractName" v-if="this.ContractCarriage.name != ''">
              <span @click="ViewContract(ContractCarriage)">{{
                this.ContractCarriage.name
              }}</span>
            </div>
          </div>
          <!--  -->
          <div class="Signed">
            <span class="CorporateIDCard check"> 法人身份证（盖公章）</span>
            <div class="demo-upload-list" v-if="CorporateCard != ''">
              <div>
                <template>
                  <div>
                    <img :src="CorporateCard" alt="" />
                  </div>
                  <div class="demo-upload-list-cover">
                    <Icon
                      type="ios-eye-outline"
                      @click.native="handleView(CorporateCard)"
                    ></Icon>
                    <Icon
                      type="ios-trash-outline"
                      @click.native="handleRemove(CorporateCard, 1)"
                    ></Icon>
                  </div>
                </template>
              </div>
            </div>
            <div class="demo-upload-list" v-else>
              <Upload
                :disabled="false"
                ref="upload"
                :show-upload-list="false"
                :on-success="handleSuccess"
                :format="['jpg', 'jpeg', 'png']"
                :max-size="20480"
                :on-format-error="handleFormatError"
                :on-exceeded-size="handleMaxSize"
                :before-upload="handleBeforeUpload"
                :headers="header"
                type="drag"
                action=""
                style="display: inline-block; width: 58px"
              >
                <div style="width: 58px; height: 58px; line-height: 58px">
                  <Icon type="ios-camera" size="20"></Icon>
                </div>
              </Upload>
            </div>
            <Modal title="" v-model="visible">
              <img :src="imgName" v-if="visible" style="width: 100%" />
              <div slot="footer"></div>
            </Modal>
          </div>
          <div>
            <!--  -->
            <div class="Signed">
              <span class="agreement">经办人授权协议</span>
              <div class="demo-upload-list" v-if="OperatorAuthorization != ''">
                <template>
                  <div>
                    <img :src="OperatorAuthorization" alt="" />
                  </div>
                  <div class="demo-upload-list-cover">
                    <Icon
                      type="ios-eye-outline"
                      @click.native="handleView(OperatorAuthorization)"
                    ></Icon>
                    <Icon
                      type="ios-trash-outline"
                      @click.native="handleRemove(OperatorAuthorization, 2)"
                    ></Icon>
                  </div>
                </template>
              </div>

              <div class="demo-upload-list" v-else>
                <Upload
                  :disabled="false"
                  ref="upload"
                  :show-upload-list="false"
                  :on-success="handleSuccess"
                  :format="['jpg', 'jpeg', 'png']"
                  :max-size="20480"
                  :on-format-error="handleFormatError"
                  :on-exceeded-size="handleMaxSize"
                  :before-upload="OperatorAuthorizationUpload"
                  :headers="header"
                  type="drag"
                  action=""
                  style="display: inline-block; width: 58px"
                >
                  <div style="width: 58px; height: 58px; line-height: 58px">
                    <Icon type="ios-camera" size="20"></Icon>
                  </div>
                </Upload>
              </div>
              <Modal title="" v-model="visible">
                <img :src="imgName" v-if="visible" style="width: 100%" />
                <div slot="footer"></div>
              </Modal>
            </div>
          </div>
        </div>
        <div style="margin-left: 13px; margin-top: 0px; width: 60%">
          <div class="ListItemcss">
            <List header="货物运输合同列表" footer="" border>
              <ListItem v-for="(item, index) in SignedList" :key="index">
                <span @click="ClickToView(item)" style="cursor: pointer">
                  <span style="color: #2d8cf0">
                    货物运输合同{{ index + 1 }}</span
                  >
                  <span style="margin-left: 30px; color: #2d8cf0">{{
                    item.createTime
                  }}</span>
                </span>
              </ListItem>
            </List>
          </div>
        </div>
      </div>
      <div v-if="this.SignedList.length == 0" slot="footer">
        <Button @click="modalNotSigned = false">取消</Button>
        <Button type="primary" :loading="SignContractbtn" @click="SignContract"
          >签约</Button
        >
      </div>
      <div v-else slot="footer">
        <Button @click="modalNotSigned = false">取消</Button>
        <Button type="primary" :loading="preservation" @click="SaveSignContract"
          >保存</Button
        >
      </div>
    </Modal>

    <Drawer
      :title="brawerTitle"
      :mask-closable="false"
      v-model="goodsVisible"
      width="700"
    >
      <div class="demo-spin-article">
        <Tabs
          v-show="!tabTabs"
          @on-click="authenticationTabs"
          v-model="cargoName1"
        >
          <TabPane label="企业认证" name="authenticationEnterprise">
            <div style="width: 100%; height: 15px"></div>
            <Form
              :model="companyLicenseForm"
              ref="companyLicenseForm"
              :rules="companyForm"
              :label-width="140"
              inline
            >
              <div style="margin-left: -57px">
                <div style="display: flex">
                  <div>
                    <FormItem label="公司名称" prop="companyName">
                      <Input
                        placeholder="请输入公司名称"
                        style="width: 205px"
                        v-model="companyLicenseForm.companyName"
                        clearable
                      />
                    </FormItem>
                  </div>
                  <div style="margin-left: 56px">
                    <FormItem label="统一社会信用代码" prop="certNo">
                      <Input
                        placeholder="请输入统一社会信用代码"
                        v-model="companyLicenseForm.certNo"
                        style="width: 155px"
                      />
                    </FormItem>
                  </div>
                </div>
                <FormItem label="公司类型">
                  <Input
                    placeholder="请输入公司类型"
                    style="width: 205px"
                    v-model="companyLicenseForm.type"
                    clearable
                  />
                </FormItem>
                <FormItem label="通讯地址" prop="street">
                  <Input
                    placeholder="请输入通讯地址"
                    style="width: 205px"
                    v-model="companyLicenseForm.street"
                    clearable
                  />
                </FormItem>
                <div style="display: flex">
                  <div style="margin-left: 14px">
                    <FormItem label="" prop="">
                      <div slot="label" class="check">法定代表人</div>
                      <Input
                        style="width: 191px"
                        placeholder="请输入法定代表人"
                        v-model="companyLicenseForm.companyUserName"
                        clearable
                      />
                    </FormItem>
                  </div>
                  <div>
                    <FormItem label="注册电话" >
                      <div slot="label">注册电话</div>
                      <Input
                        placeholder="请输入注册电话"
                        style="width: 205px"
                        v-model="companyLicenseForm.companyPhone"
                        clearable
                      />
                    </FormItem>
                  </div>
                </div>

                <FormItem label="开户银行" >
                  <div slot="label">开户银行</div>
                  <Input
                    placeholder="请输入开户银行"
                    style="width: 205px"
                    v-model="companyLicenseForm.bankName"
                    clearable
                  />
                </FormItem>
                <FormItem label="对公账户" >
                  <div slot="label">对公账户</div>
                  <Input
                    placeholder="请输入对公账户"
                    style="width: 205px"
                    v-model="companyLicenseForm.bankCode"
                    clearable
                  />
                </FormItem>
              </div>
              <Row>
                <Col span="8">
                  <div
                    v-if="companyPicFileUrl"
                    style="
                      width: 148px;
                      height: 92px;
                      line-height: 75px;
                      margin-bottom: 7px;
                    "
                  >
                    <div class="demo-upload-list-company">
                      <img
                        v-if="companyPicFileUrl != ''"
                        style="width: 58px"
                        height="100px"
                        :src="companyPicFileUrl"
                      />
                      <img
                        style="width: 58px"
                        height="100px"
                        src="@/assets/vehicleAtes/owner3.png"
                      />
                      <div
                        v-if="companyPicFileUrl != ''"
                        class="demo-upload-list-company-cover"
                      >
                        <Icon
                          type="ios-eye-outline"
                          @click.stop="showPic(companyPicFileUrl)"
                        ></Icon>
                        <Icon
                          type="ios-trash-outline"
                          @click.stop="handleRemove(companyPicFileUrl, 1)"
                        ></Icon>
                      </div>
                    </div>
                  </div>
                  <Upload
                    class="Upload-border"
                    v-else
                    :on-progress="BusinessLicen"
                    :beforeUpload="beforeUpload"
                    ref="companyUpload"
                    :show-upload-list="false"
                    :on-success="handleSuccess"
                    :format="['jpg', 'jpeg', 'png']"
                    :on-format-error="handleFormatError"
                    :headers="header"
                    type="drag"
                    :action="upLoadCompanyLicense"
                    style="display: inline-block"
                  >
                    <div style="width: 148px; height: 92px; line-height: 75px">
                      <div class="demo-upload-list-company">
                        <img
                          v-if="companyPicFileUrl != ''"
                          style="width: 58px"
                          height="100px"
                          :src="companyPicFileUrl"
                        />
                        <img
                          style="width: 58px"
                          height="100px"
                          src="@/assets/vehicleAtes/owner3.png"
                        />
                        <div
                          v-if="companyPicFileUrl != ''"
                          class="demo-upload-list-company-cover"
                        >
                          <Icon
                            type="ios-eye-outline"
                            @click.stop="showPic(companyPicFileUrl)"
                          ></Icon>
                          <Icon
                            type="ios-trash-outline"
                            @click.stop="handleRemove(companyPicFileUrl, 1)"
                          ></Icon>
                        </div>
                      </div>
                    </div>
                  </Upload>
                  <div class="demo-uploadcss-compny">
                    <template>
                      <Progress
                        v-if="progressBusinessLicen"
                        text-inside
                        :percent="load"
                        :stroke-width="3"
                      ></Progress>
                    </template>
                  </div>
                  <div style="margin-top: 15px" class="check">
                    <span class="check_font">营业执照</span>
                  </div>
                </Col>
              </Row>
            </Form>
          </TabPane>
          <TabPane label="联系人信息" name="contactInformation">
            <div style="width: 100%; height: 15px">
              <Form
                :model="companyLicenseForm2"
                ref="companyLicenseForm2"
                :rules="companyForm2"
                :label-width="110"
                inline
              >
                <div style="margin-left: -58px">
                  <FormItem label="姓名" prop="contactName">
                    <Input
                      style="width: 220px"
                      placeholder="请输入姓名"
                      v-model="companyLicenseForm2.contactName"
                    />
                  </FormItem>
                  <FormItem label="联系电话" prop="contactPhone">
                    <Input
                      placeholder="请输入联系电话"
                      v-model="companyLicenseForm2.contactPhone"
                      clearable
                      style="width: 220px"
                    />
                  </FormItem>
                </div>
                <div style="margin-left: -16px">
                  <FormItem label="身份有效期" prop="contactEndDate">
                    <DatePicker
                      type="date"
                      style="width: 175px"
                      format="yyyyMMdd"
                      placeholder="请选择身份有效期"
                      :value="companyLicenseForm2.contactEndDate"
                      @on-change="companyEndDate"
                    ></DatePicker>
                  </FormItem>
                  <FormItem label="身份证号" prop="contactNum">
                    <Input
                      placeholder="请输入身份证号"
                      style="width: 220px"
                      v-model="companyLicenseForm2.contactNum"
                      clearable
                    />
                  </FormItem>
                </div>
                <Row style="margin-top: 20px">
                  <Col span="8">
                    <div
                      v-if="enterpriseIdCardFontPicFileUrl"
                      style="
                        width: 148px;
                        height: 92px;
                        line-height: 75px;
                        margin-bottom: 7px;
                      "
                    >
                      <div class="demo-upload-list-company">
                        <img
                          v-if="enterpriseIdCardFontPicFileUrl != ''"
                          style="width: 58px"
                          height="100px"
                          :src="enterpriseIdCardFontPicFileUrl"
                        />
                        <img
                          style="width: 58px"
                          height="100px"
                          src="@/assets/vehicleAtes/owner1.png"
                        />
                        <div
                          v-if="enterpriseIdCardFontPicFileUrl != ''"
                          class="demo-upload-list-company-cover"
                        >
                          <Icon
                            type="ios-eye-outline"
                            @click.stop="
                              showPic(enterpriseIdCardFontPicFileUrl)
                            "
                          ></Icon>
                          <Icon
                            type="ios-trash-outline"
                            @click.stop="
                              handleRemove(enterpriseIdCardFontPicFileUrl, 2)
                            "
                          ></Icon>
                        </div>
                      </div>
                    </div>
                    <Upload
                      class="Upload-border"
                      v-else
                      :on-progress="enterprIseidCard"
                      :beforeUpload="beforeUpload"
                      ref="companyUpload"
                      :show-upload-list="false"
                      :on-success="enterpriseID"
                      :format="['jpg', 'jpeg', 'png']"
                      :on-format-error="handleFormatError"
                      :headers="header"
                      :data="{
                        fileType: 'IDCARD_FONT_PIC',
                        userId: idCardIdForms.userId,
                      }"
                      type="drag"
                      :action="uploadIdCardPic"
                      style="display: inline-block; width: 148px"
                    >
                      <div
                        style="width: 148px; height: 92px; line-height: 75px"
                      >
                        <div class="demo-upload-list-company">
                          <img
                            v-if="enterpriseIdCardFontPicFileUrl != ''"
                            style="width: 58px"
                            height="100px"
                            :src="enterpriseIdCardFontPicFileUrl"
                          />
                          <img
                            style="width: 58px"
                            height="100px"
                            src="@/assets/vehicleAtes/owner1.png"
                          />
                          <div
                            v-if="enterpriseIdCardFontPicFileUrl != ''"
                            class="demo-upload-list-company-cover"
                          >
                            <Icon
                              type="ios-eye-outline"
                              @click.stop="
                                showPic(enterpriseIdCardFontPicFileUrl)
                              "
                            ></Icon>
                            <Icon
                              type="ios-trash-outline"
                              @click.stop="
                                handleRemove(enterpriseIdCardFontPicFileUrl, 2)
                              "
                            ></Icon>
                          </div>
                        </div>
                      </div>
                    </Upload>
                    <div class="demo-uploadcss-compny">
                      <template>
                        <Progress
                          v-if="progressFront"
                          text-inside
                          :percent="load"
                          :stroke-width="3"
                        ></Progress>
                      </template>
                    </div>
                    <div style="margin-top: 15px" class="check">
                      <span class="check_font">身份证正面</span>
                    </div>
                  </Col>
                  <Col span="8">
                    <div
                      v-if="enterprIseidCardBackPicFileUrl"
                      style="
                        width: 148px;
                        height: 92px;
                        line-height: 75px;
                        margin-bottom: 7px;
                      "
                    >
                      <div class="demo-upload-list-company">
                        <img
                          v-if="enterprIseidCardBackPicFileUrl != ''"
                          style="width: 58px"
                          height="100px"
                          :src="enterprIseidCardBackPicFileUrl"
                        />
                        <img
                          style="width: 58px"
                          height="100px"
                          src="@/assets/vehicleAtes/owner2.png"
                        />
                        <div
                          v-if="enterprIseidCardBackPicFileUrl != ''"
                          class="demo-upload-list-company-cover"
                        >
                          <Icon
                            type="ios-eye-outline"
                            @click.stop="
                              showPic(enterprIseidCardBackPicFileUrl)
                            "
                          ></Icon>
                          <Icon
                            type="ios-trash-outline"
                            @click.stop="
                              handleRemove(enterprIseidCardBackPicFileUrl, 3)
                            "
                          ></Icon>
                        </div>
                      </div>
                    </div>
                    <Upload
                      class="Upload-border"
                      v-else
                      :on-progress="enterprIseidCardf"
                      :beforeUpload="beforeUpload"
                      ref="companyUpload"
                      :show-upload-list="false"
                      :on-success="reverseIDCard"
                      :format="['jpg', 'jpeg', 'png']"
                      :on-format-error="handleFormatError"
                      :headers="header"
                      :data="{
                        fileType: 'IDCARD_BACK_PIC',
                        userId: idCardIdForms.userId,
                      }"
                      type="drag"
                      :action="uploadIdCardPic"
                      style="display: inline-block; width: 148px"
                    >
                      <div
                        style="width: 148px; height: 92px; line-height: 75px"
                      >
                        <div class="demo-upload-list-company">
                          <img
                            v-if="enterprIseidCardBackPicFileUrl != ''"
                            style="width: 58px"
                            height="100px"
                            :src="enterprIseidCardBackPicFileUrl"
                          />
                          <img
                            style="width: 58px"
                            height="100px"
                            src="@/assets/vehicleAtes/owner2.png"
                          />
                          <div
                            v-if="enterprIseidCardBackPicFileUrl != ''"
                            class="demo-upload-list-company-cover"
                          >
                            <Icon
                              type="ios-eye-outline"
                              @click.stop="
                                showPic(enterprIseidCardBackPicFileUrl)
                              "
                            ></Icon>
                            <Icon
                              type="ios-trash-outline"
                              @click.stop="
                                handleRemove(enterprIseidCardBackPicFileUrl, 3)
                              "
                            ></Icon>
                          </div>
                        </div>
                      </div>
                    </Upload>
                    <div class="demo-uploadcss-compny">
                      <template>
                        <Progress
                          v-if="progressReverse"
                          text-inside
                          :percent="load"
                          :stroke-width="3"
                        ></Progress>
                      </template>
                    </div>
                    <div style="margin-top: 15px" class="check">
                      <span class="check_font">身份证反面</span>
                    </div>
                  </Col>
                </Row>
              </Form>
            </div>
          </TabPane>
        </Tabs>
        <div class="demo-drawer-footers-company">
          <!-- display: flex; justify-content: space-between -->
          <div style="">
            <div></div>
            <!-- v-if="this.form.companyType == 2" -->
            <Button
              type="warning"
              @click="submitCompanyLicenseInfo"
              :loading="loadinLicenseInfo"
              >保存资料</Button
            >
          </div>
        </div>
        <Spin size="large" fix v-if="spinShow"></Spin>
      </div>
    </Drawer>
    <!-- 审核不审核通过 -->
    <Modal v-model="auditFailedModal" title="审核不通过">
      <span style="font-size: 15px">
        {{ confirmRejection }}
      </span>
      <Input
        style="margin-top: 10px"
        v-model="AuditFailedInput"
        type="textarea"
        :rows="4"
        placeholder="请输入审核不通过原因"
      />
      <div slot="footer">
        <Button @click="auditFailedModal = false">取消</Button>
        <Button
          :loading="loadingbut"
          type="primary"
          @click="auditRejectDetermine"
          >确定</Button
        >
      </div>
    </Modal>
    <operationRecord
      @operationRecordEnd="operationRecordEnd"
      :operationRecordData="operationRecordData"
      :operationRecordModal="this.operationRecordModal"
    >
    </operationRecord>
    <addOwner
      :data="form"
      :type="showType"
      v-model="showUser"
      @on-submit="getDataList"
    />
  </div>
</template>

<script>
// 根据你的实际请求api.js位置路径修改
import { getCompanyVoList } from "@/api/user";
import {
  disableUser,
  enableUser,
  collectionFile,
  offlineContract,
  getOfflineContract,
  signAontract,
  addDownloadRecord,
  uploadPic,
} from "@/api/index"; //上传协议
// 根据你的实际添加编辑组件位置路径修改
import { getStore } from "@/libs/storage";
import excel from "@/libs/excel";
// // // // // // // // // // // // // // // //
// 根据你的实际请求api.js位置路径修改
import {
  saveIdCardInfo,
  getIdCarDInfo,
  saveCompanyLicenseInfo,
  getCompanyEnterprise,
} from "@/api/user";
import * as imageConversion from "image-conversion";
import {
  uploadIdCardPic,
  upLoadCompanyLicense,
  uploadHeadPortrait,
} from "@/api/index";
// 新增货主
import addOwner from "./addOwner.vue";
import operationRecord from "@/views/componentsonn_source_goods/operationRecord";
export default {
  name: "companyInfo",
  components: { addOwner, operationRecord },
  data() {
    return {
      uploadPic: uploadPic,
      uploadHeadPortrait: uploadHeadPortrait,
      tabTabs: false,
      tabTabsPersonal: false,
      tabTabsEnterprise: false,
      tabTabss: false,
      auditFailedModal: false, // 审核不通过
      confirmRejection: "",
      AuditFailedInput: "",
      loadingbut: false,

      spinShow: false,
      //新增货主
      showUser: false,
      showType: "0",

      approveButtonShow: true, //
      enterpris: "",
      SignContractbtn: false, //签约加载
      preservation: false, //确定加载
      OwnerId: "", //货主id
      // uploadList: [],
      SignedList: [],
      CorporateCard: "", //法人身份证
      OperatorAuthorization: "", //经办人授权协议
      ContractCarriage: [], //上传运输合同
      UploadHandler: { key: "empty" },
      UploadLegalLersonIdCard: { key: "empty" },
      driverGroupId: { driverGroupId: "" }, //上传协议
      collectionFile: collectionFile, //上传协议
      modalNotSigned: false, //签约弹框显示隐藏
      openSearch: true, // 显示搜索
      showDrawer: false, // 显示添加编辑抽屉
      loading: true, // 表单加载状态
      drop: false,
      header: {
        accessToken: getStore("accessToken"),
      },
      accessToken: getStore("accessToken"),
      dropDownIcon: "ios-arrow-down",
      searchForm: {
        // 搜索框初始化对象
        pageNumber: 1, // 当前页数
        pageSize: 10, // 页面大小
        sort: "createTime", // 默认排序字段
        order: "desc", // 默认排序方式
        companyName: "",
        registStatus: "", //默认查全部
        companyPhone: "",
      },

      form: {},
      columns: [
        {
          type: "selection",
          width: 60,
          align: "center",
        },
        {
          title: "#",
          type: "index",
          width: 60,
        },
        {
          title: "状态",
          key: "status",
          // align: "center",
          width: 100,
          render: (h, params) => {
            if (params.row.status == 0) {
              return h("div", [
                h("Badge", {
                  props: {
                    status: "success",
                    text: "启用",
                  },
                }),
              ]);
            } else if (params.row.status == -1) {
              return h("div", [
                h("Badge", {
                  props: {
                    status: "error",
                    text: "禁用",
                  },
                }),
              ]);
            }
          },
          filters: [
            {
              label: "启用",
              value: 0,
            },
            {
              label: "禁用",
              value: -1,
            },
          ],
          filterMultiple: false,
          filterRemote: (e) => {
            let v = "";
            if (e.length > 0) {
              v = e[0];
            }
            this.searchForm.status = v;
            this.searchForm.pageNumber = 1;
            this.getDataList();
          },
        },
        {
          title: "头像",
          key: "avatar",
          width: 80,
          // align: "center",
          render: (h, params) => {
            let avatarUrl = "";
            if (
              params.row.avatar ==
              "https://ooo.0o0.ooo/2019/04/28/5cc5a71a6e3b6.png"
            ) {
              avatarUrl = "https://ooo.0o0.ooo/2019/04/28/5cc5a71a6e3b6.png";
            } else if (params.row.avatar == "" || params.row.avatar == null) {
              avatarUrl = "https://ooo.0o0.ooo/2019/04/28/5cc5a71a6e3b6.png";
            } else {
              avatarUrl = this.$baseUrl + params.row.avatar;
            }
            return h("Avatar", {
              props: {
                src: avatarUrl,
              },
            });
          },
        },
        {
          title: "登录账号",
          key: "mobile",
          minWidth: 130,
          sortable: false,
        },
        {
          title: "公司名称",
          key: "companyName",
          minWidth: 180,
          sortable: false,
          tooltip: true,
        },

        {
          title: "联系人",
          key: "contactName",
          minWidth: 100,
          sortable: false,
          tooltip: true,
        },
        {
          title: "联系电话",
          key: "companyPhone",
          minWidth: 140,
          sortable: false,
          render: (h, params) => {
            return h("div", params.row.mobile);
          },
        },
        {
          title: "统一社会信用代码",
          key: "certNo",
          minWidth: 200,
          sortable: false,
        },
        {
          title: "公司类型",
          key: "type",
          minWidth: 220,
          tooltip: true,
        },
        {
          title: "通讯地址",
          key: "street",
          minWidth: 270,
          sortable: false,
          tooltip: true,
        },

        {
          title: "更新时间",
          key: "updateTime",
          minWidth: 180,
          sortable: false,
        },
        {
          title: "创建时间",
          key: "createTime",
          minWidth: 180,
          sortable: false,
        },
        {
          title: "认证状态",
          key: "capital",
          minWidth: 120,
          sortable: false,
          align: "center",
          fixed: "right",
          render: (h, params) => {
            let titleText = "";
            let colorStatus = "";
            if (params.row.registStatus == 0) {
              colorStatus = "error";
              titleText = "未认证";
            } else if (params.row.registStatus == 2) {
              colorStatus = "processing";
              titleText = "待审核";
            } else if (params.row.registStatus == 1) {
              colorStatus = "success";
              titleText = "已认证";
            }

            return h("div", [
              h("Badge", {
                props: {
                  status: colorStatus,
                  text: titleText,
                },
              }),
            ]);
          },
        },
        {
          title: "操作",
          slot: "action",
          align: "center",
          fixed: "right",
          width: 140,
          // render: (h, params) => {
          //   return h("div", [
          //     h(
          //       "a",
          //       {
          //         on: {
          //           click: () => {
          //             this.edit(params.row);
          //           },
          //         },
          //       },
          //       "审核"
          //     ),
          //   ]);
          // },
        },
      ],
      data: [], // 表单数据
      pageNumber: 1, // 当前页数
      pageSize: 10, // 页面大小
      total: 0, // 表单数据总数
      ////////////////////////  ////////////////////////  ////////////////////////
      cargoName: "realNameAuthentication",
      cargoName1: "authenticationEnterprise",
      brawerTitle: "托运人认证信息",
      uploadIdCardPic: uploadIdCardPic,
      upLoadCompanyLicense: upLoadCompanyLicense,
      goodsVisible: false,
      idCardIdForms: {},
      idCardIdFormUserIds: {},
      companyLicenseForms: {},
      loadinLicenseInfo: false,
      loadRealInspection: false, // 实名检验
      loadingsubmi: false,
      idCardIdForm: {
        userId: "",
        name: "", //名字
        num: "", //身份证号
        address: "", //居住地址
        birth: "", //生日
        sex: "", //性别
        nationality: "", //籍贯
        startDate: "", //身份证开始有效期
        endDate: "", //身份证结束有效期
        issue: "", //发证机关
        idCardFontPicFileId: "", //身份证正面照ID
        idCardBackPicFileId: "", //身份证背面照ID
        holdIdCardFileId: "", //手持身份证照片ID
        contactUumber: "", //联系人电话
      },
      companyLicenseForm: {
        userId: "",
        companyName: "", //公司名称
        companyUserName: "", //法人
        certNo: "", //公司统一社会信用代码
        companyPhone: "", //公司注册电话
        street: "", //通讯地址

        bankName: "", //开户行
        bankCode: "", //开户行账号
        type: "", //公司类型
        capital: "", //注册资金
        business: "", //经营范围
        startDate: "", //注册时间
        endDate: "", //截止日期
        companyLicenseFileId: "", //公司营业执照图片地址
        authorizationId: "", //委托授权书
        //联系人
        contactPhone: "", //联系人 --- 电话
        contactNum: "", //联系人 ---  身份证号
        contactName: "", //联系人 --- 姓名
        contactAddress: "", //联系人 --- 地址
        contactBirth: "", //联系人 --- 生日
        contactSex: "", //联系人 --- 性别
        contactNationality: "", //联系人 ---  民族
        contactStartDate: "", //联系人 --- 身份证起始日期
        contactEndDate: "", //联系人 --- 身份证结束日期
        contactIssue: "", //联系人 --- 签发机关
        contactIdCardFontPicFileId: "", //联系人 --- 身份证前置照片地址
        contactIdCardBackPicFileId: "", //联系人 --- 身份证后置照片地址
        contactHoldIdCardFileId: "", //联系人 --- 手持身份证照片ID
        //法人
        legalpersonNum: "", //法人 --- 身份证号
        legalpersonName: "", //法人 --- 姓名
        legalpersonPhone: "", //	法人 --- 联系电话
        legalpersonEndDate: "", //法人 --- 身份证结束日期
        legalpersonIdCardFontPicFileId: "", //	法人 --- 身份证前置照片地址
        legalpersonIdCardBackPicFileId: "", //法人 --- 身份证后置照片地址
      },
      // 联系人
      companyLicenseForm2: {
        contactName: "",
        contactPhone: "",
        contactEndDate: "",
        contactNum: "",
      },
      companyForm2: {
        contactName: [
          { required: true, message: "请输入姓名", trigger: "blur" },
        ],
        contactPhone: [
          { required: true, message: "请输入联系电话", trigger: "blur" },
        ],

        contactEndDate: [
          { required: true, message: "请输入身份有效期", trigger: "blur" },
        ],
        contactNum: [
          { required: true, message: "请输入身份证号", trigger: "blur" },
        ],
      },
      // 法人信息
      companyLicenseForm3: {
        legalpersonName: "",
        legalpersonPhone: "",
        legalpersonEndDate: "",
        legalpersonNum: "",
      },
      companyForm3: {
        legalpersonName: [
          { required: true, message: "请输入姓名", trigger: "blur" },
        ],
        legalpersonPhone: [
          { required: true, message: "请输入联系电话", trigger: "blur" },
        ],
        legalpersonEndDate: [
          { required: true, message: "请输入身份有效期", trigger: "blur" },
        ],
        legalpersonNum: [
          { required: true, message: "请输入身份证号", trigger: "blur" },
        ],
      },
      companyForm: {
        companyName: [
          { required: true, message: "请输入公司名称", trigger: "blur" },
        ],
        companyUserName: [
          { required: true, message: "请输入法定代表人", trigger: "blur" },
        ],
        street: [
          { required: true, message: "请输入通讯地址", trigger: "blur" },
        ],
        companyPhone: [
          { required: true, message: "请输入法人电话", trigger: "blur" },
        ],

        // bankName: [
        //   { required: true, message: "请输入开户银行", trigger: "blur" },
        // ],
        // bankCode: [
        //   { required: true, message: "请输入对公账户", trigger: "blur" },
        // ],
        certNo: [
          {
            required: true,
            message: "请输入统一社会信用代码",
            trigger: "blur",
          },
        ],
        // type: [{ required: true, message: "请输入公司类型", trigger: "blur" }],
      },
      progressBusinessLicen: false, // 营业执照
      progressCardBack: false, // 个人认证 身份证反面
      progressFlagnum: false, // 个人认证 身份证正面
      personalIDCard: false, // 个人认证 手拿身份证

      progressFront: false, // 联系人信息 身份证正面
      progressReverse: false, // 联系人信息 身份证反面
      handHeldProgress: false, //手持身份证联系人

      corporateFront: false, // 法人信息： 身份证正面
      corporateReverse: false, // 法人信息： 身份证反面
      progressAgreement: false, //授权协议书
      handHeldCorporate: false, //手持身份证法人

      idCardFontPicFileUrl: "", // 个人认证 身份证正面
      idCardBackPicFileUrl: "", // 个人认证 身份证反面
      personalIDCardUrl: "", // 个人认证 手拿身份证
      personalIDCardard: false,
      enterpriseIdCardFontPicFileUrl: "", // 联系人信息 身份证正面
      enterprIseidCardBackPicFileUrl: "", // 联系人信息 身份证反面
      handHeldProgressIdCard: "", //手持身份证联系人

      corporateidCardFontPicFileUrl: "", // 法人信息： 身份证正面
      corporateidCardBackPicFileUrl: "", // 法人信息： 身份证反面
      holdIdCardFileId: "", //手持身份证法人

      companyPicFileUrl: "", // 营业执照
      agreementUrl: "", //授权协议书

      // 表单验证规则
      idCardBackPicFileList: [],
      formValidate: {
        name: [{ required: true, message: "请输入真实姓名", trigger: "blur" }],
        num: [{ required: true, message: "请输入身份证号", trigger: "blur" }],
        birth: [{ required: true, message: "请输入出生日期", trigger: "blur" }],
        sex: [{ required: true, message: "请输入性别", trigger: "blur" }],
        startDate: [
          { required: true, message: "请输入开始日期", trigger: "blur" },
        ],
        endDate: [
          { required: true, message: "请输入身份有效期", trigger: "blur" },
        ],
        address: [
          { required: true, message: "请输入家庭地址", trigger: "blur" },
        ],
        contactsName: [
          { required: true, message: "请输入联系人姓名", trigger: "blur" },
        ],
        contactUumber: [
          { required: true, message: "请输入联系人电话", trigger: "blur" },
        ],
        contactPhone: [
          { required: true, message: "请输入联系电话", trigger: "blur" },
        ],
      },
      load: 0,
      progressBusinessLicen: false, // 关闭进度条
      progressCardBack: false, // 关闭进度条
      progressFlagnum: false, // 关闭进度条
      choice: "",
      addOwnerShow: false,
      // / 操作记录
      operationRecordModal: false,
      operationRecordData: {},
    };
  },
  methods: {
    // 操作记录点击
    operationRecordClick(row) {
      this.operationRecordModal = true;
      this.operationRecordData.logType = 1;
      this.operationRecordData.oid = row.userId;
    },
    // 操作记录关闭
    operationRecordEnd(val) {
      this.operationRecordModal = val;
      this.operationRecordData = {};
    },
    getAge(value) {
      if (value) {
        let birthdays = new Date(value);
        let d = new Date();
        let age =
          d.getFullYear() -
          birthdays.getFullYear() -
          (d.getMonth() < birthdays.getMonth() ||
          (d.getMonth() == birthdays.getMonth() &&
            d.getDate() < birthdays.getDate())
            ? 1
            : 0);
        return age;
      }
      return "";
    },
    // 个人企业
    shipperClick(val) {
      if (val == "personalTabs") {
        this.searchForm.companyType = "1";
      } else {
        this.searchForm.companyType = "2";
      }
      this.getDataList();
    },
    // 新增货主
    addCargOwner() {
      this.showType = "2";
      this.showUser = true;
    },
    addAuthentication(val) {},
    init() {
      this.getDataList();
    },
    changePage(v) {
      this.searchForm.pageNumber = v;
      this.getDataList();
      this.clearSelectAll();
    },
    changePageSize(v) {
      this.searchForm.pageSize = v;
      this.getDataList();
    },
    handleSearch() {
      this.searchForm.pageNumber = 1;
      this.searchForm.pageSize = 10;
      this.getDataList();
    },
    handleReset() {
      this.$refs.searchForm.resetFields();
      this.searchForm.pageNumber = 1;
      this.searchForm.pageSize = 10;
      this.searchForm.registStatus = "";
      // 重新加载数据
      this.getDataList();
    },
    idCardIdFormBirth(val) {
      this.idCardIdForm.birth = val;
    },
    idCardIdFormEndDate(val) {
      this.idCardIdForm.endDate = val;
    },
    companyEndDate(val) {
      this.companyLicenseForm2.contactEndDate = val;
    },
    companylegalpersonEndDate(val) {
      this.companyLicenseForm3.legalpersonEndDate = val;
    },
    changeSort(e) {
      this.searchForm.sort = e.key;
      this.searchForm.order = e.order;
      if (e.order === "normal") {
        this.searchForm.order = "";
      }
      this.getDataList();
    },
    clearSelectAll() {
      this.$refs.table.selectAll(false);
    },
    getDataList() {
      this.loading = true;
      getCompanyVoList(this.searchForm).then((res) => {
        this.loading = false;
        if (res.success) {
          this.data = res.result.records;
          this.total = res.result.total;
          if (this.data.length == 0 && this.searchForm.pageNumber > 1) {
            this.searchForm.pageNumber -= 1;
            this.getDataList();
          }
        }
      });
    },

    // 删除图片
    handleRemove(file, num) {
      if (num == 1) {
        // 营业执照
        this.companyPicFileUrl = "";
      } else if (num == 2) {
        // 联系人信息身份证正面
        this.enterpriseIdCardFontPicFileUrl = "";
      } else if (num == 3) {
        // 联系人信息身份证反面
        this.enterprIseidCardBackPicFileUrl = "";
      } else if (num == 4) {
        // 法人信息身份证正面
        this.corporateidCardFontPicFileUrl = "";
      } else if (num == 5) {
        //法人信息身份证反面
        this.corporateidCardBackPicFileUrl = "";
      } else if (num == 6) {
        //委托授权书照片
        this.agreementUrl = "";
      } else if (num == 7) {
        //个人认证身份证反面
        this.idCardFontPicFileUrl = "";
      } else if (num == 8) {
        //个人认证身份证反面
        this.idCardBackPicFileUrl = "";
      }
    },
    // 图片放大
    handleView(url) {
      let image = new Image();
      image.src = url;
      let viewer = new Viewer(image, {
        hidden: function () {
          viewer.destroy();
        },
      });
      viewer.show();
    },
    // 上传图片之前的钩子，参数为上传的图片法人身份证
    handleBeforeUpload(file) {
      const reader = new FileReader();
      reader.readAsDataURL(file);
      reader.onload = () => {
        const _base64 = reader.result;
        file.url = _base64;
        this.CorporateCard = file.url;
      };
      this.UploadHandler = file;
      // this.CorporateCard = this.$refs.upload.fileList;
      this.fileall = file;
      return false;
    },
    // 上传图片之前的钩子，参数为上传的图片经办人授权协议
    OperatorAuthorizationUpload(file) {
      const reader = new FileReader();
      reader.readAsDataURL(file);
      reader.onload = () => {
        const _base64 = reader.result;
        file.url = _base64;
        this.OperatorAuthorization = file.url;
      };
      this.UploadLegalLersonIdCard = file;
      // this.OperatorAuthorization = this.$refs.upload.fileList;
      this.fileall = file;
      return false;
    },
    // 图片超出指定大小限制时的钩子
    handleMaxSize(file) {
      this.$Message.error("图片超出了最大存储限制");
    },
    //图片格式验证失败时的钩子
    handleFormatError(file) {
      this.$Message.error("图片格式错误,指定上传图片格式 jpg、jpeg、png");
    },
    // 图片上传成功
    handleSuccess(res, file, fileList) {
      this.spinShow = true;
      if (res.result != null) {
        setInterval(() => {
          this.spinShow = false;
        }, 1000);
        var a = res.result;
        this.enlargeImig =
          this.$baseUrl +
          "/freight/file/view/" +
          a +
          "?accessToken=" +
          this.accessToken +
          "&preview=true";
      } else {
        setInterval(() => {
          this.spinShow = false;
        }, 1000);
        this.$Message.error(res.message);
      }
    },
    // 是否签约/未签约
    NotSigned(row) {
      this.OwnerId = row.companyId;
      this.modalNotSigned = true;
      this.CorporateCard = ""; //法人身份证
      this.OperatorAuthorization = []; //经办人授权协议
      this.ContractCarriage = []; //上传运输合同
      this.SignedList = [];
    },
    // 是否签约/签约
    YeiSigned(row) {
      this.OwnerId = row.companyId;
      this.modalNotSigned = true;
      let data = {
        companyUserId: row.userId,
      };
      getOfflineContract(data).then((res) => {
        if (res.result.contractDetails.length > 0) {
          this.SignedList = res.result.contractDetails;
          this.SignedList.forEach((item) => {
            item.contract =
              this.$baseUrl +
              "/freight/file/view/" +
              item.fileId +
              "?accessToken=" +
              this.accessToken +
              "&preview=true";
          });
        }
        this.CorporateCard =
          this.$baseUrl +
          "/freight/file/view/" +
          res.result.corporateIdCard +
          "?accessToken=" +
          this.accessToken +
          "&preview=true";
        this.OperatorAuthorization =
          this.$baseUrl +
          "/freight/file/view/" +
          res.result.authorizationId +
          "?accessToken=" +
          this.accessToken +
          "&preview=true";
      });
      this.ContractCarriage = []; //上传运输合同
    },
    //  是否签约/查看合同
    ClickToView(item) {
      window.open(item.contract, "_blank");
    },
    // 运输合同上传成功
    sendSuccess(response, file, fileList) {
      this.modalNotSigned = false;
      this.$Message.info("上传成功");
      // this.getDataList();
    },
    //上传运输合同
    ContractCarriageUpload(file) {
      if (file.type == "application/pdf") {
        this.ContractCarriage = file;
      } else {
        this.$Message.warning("上传的合同必须是PDF文件格式");
      }
      return false;
    },
    // 点击查看合同
    ViewContract(v) {
      // console.log(v);
      //   let url =
      //   this.$baseUrl +
      //   "/freight/file/view/" +
      //   v +
      //   "?accessToken=" +
      //   this.accessToken +
      //   "&preview=true";
      // window.open(url, "_blank");
    },

    edit(v) {
      this.$refs.companyLicenseForm.resetFields();
      this.$refs.companyLicenseForm2.resetFields();

      this.cargoName1 = "authenticationEnterprise";
      this.addOwnerShow = true;
      this.idCardFontPicFileUrl = ""; // 个人认证 身份证正面
      this.idCardBackPicFileUrl = ""; // 个人认证 身份证反面
      this.personalIDCardUrl = ""; // 个人认证 手拿身份证
      this.enterpriseIdCardFontPicFileUrl = ""; // 联系人信息 身份证正面
      this.enterprIseidCardBackPicFileUrl = ""; // 联系人信息 身份证反面
      (this.handHeldProgressIdCard = ""), //手持身份证联系人
        (this.corporateidCardFontPicFileUrl = ""); // 法人信息： 身份证正面
      this.corporateidCardBackPicFileUrl = ""; // 法人信息： 身份证反面
      this.holdIdCardFileId = ""; //手持身份证法人
      this.companyPicFileUrl = ""; // 营业执照
      this.agreementUrl = ""; //授权协议书
      this.idCardIdForm = {};
      this.companyLicenseForm = {};
      //联系电话
      this.contactUumber = v.mobile;

      if (v.companyType == 1) {
        this.choice = "personal"; //个人
        this.tabTabs = true;
      } else if (v.companyType == 2) {
        this.choice = "enterprise"; //企业
        this.tabTabs = false;
      } else {
        // return this.$Message.warning("未认证");
      }
      this.spinShow = true;

      this.idCardFontPicFileUrl = "";
      this.idCardBackPicFileUrl = "";
      this.companyPicFileUrl = "";

      // 转换null为""
      for (let attr in v) {
        if (v[attr] == null) {
          v[attr] = "";
        }
      }
      let str = JSON.stringify(v);
      let data = JSON.parse(str);
      this.form = data;
      this.showType = "1";
      // this.showDrawer = true;
      this.companyLicenseForm = data;
      this.idCardIdForm = data;
      this.idCardIdForms = data;
      this.companyLicenseForms = data;
      this.openModal("edit", data);
      // 新增用户
      if (this.tabTabs) {
        this.brawerTitle = "个人证信息";
        // 个人认证
        this.nameAuthentication();
      } else {
        this.brawerTitle = "企业认证信息";
        // 企业认证
        this.enterpriseCertification();
      }
      this.goodsVisible = true;
      if (v.registStatus == 0) {
        this.companyLicenseForm2.contactPhone = v.mobile;
      }
      setInterval(() => {
        this.spinShow = false;
      }, 1000);
    },
    openModal(status, row) {
      this.form1 = this.$options.data().companyLicenseForm; // 初始化表单
      this.modalStatus = status;
      if (status === "add") {
        this.$refs["formValidate"].resetFields();
        this.modal1 = true;
      } else if (status === "edit") {
        // 修改渠道时效维护
        // 渲染编辑的表单数据
        let tempForm = this.$rowEditFormNumToStr(this.companyLicenseForm, row);
        this.companyLicenseForm = tempForm;
        setTimeout(() => {
          this.modal1 = true;
        }, 100);
      }
    },
    // 图片拼接
    imgUrl(val) {
      let url = "";
      if (val) {
        url = this.$baseUrl + val;
      }
      return url;
    },
    // 个人认证
    nameAuthentication() {
      getIdCarDInfo({ userId: this.idCardIdForms.userId }).then((res) => {
        if (res.success) {
          if (res.result != null) {
            this.idCardIdForm = res.result;
            this.idCardIdForm.contactPhone = this.contactUumber;
            this.idCardIdForm.startDate =
              res.result.startDate == null
                ? ""
                : res.result.startDate.replaceAll("-", "");
            this.idCardIdForm.endDate =
              res.result.endDate == null
                ? ""
                : res.result.endDate.replaceAll("-", "");

            if (this.idCardIdForm.idCardFontPicFileId != null) {
              this.idCardFontPicFileUrl = this.imgUrl(
                this.idCardIdForm.idCardFontPicFileId
              );
            }
            if (this.idCardIdForm.idCardBackPicFileId != null) {
              this.idCardBackPicFileUrl = this.imgUrl(
                this.idCardIdForm.idCardBackPicFileId
              );
            }
            if (this.idCardIdForm.holdIdCardFileId != null) {
              this.personalIDCardUrl = this.imgUrl(
                this.idCardIdForm.holdIdCardFileId
              );
            }
          } else {
            this.$Message.error(res.message);
          }
        }
      });
    },
    // 企业认证
    enterpriseCertification() {
      getCompanyEnterprise({ userId: this.companyLicenseForms.userId }).then(
        (res) => {
          if (res.success) {
            if (res.result != null) {
              // 企业信息
              this.companyLicenseForm.companyName =
                res.result.companyLicense.companyName;

              this.companyLicenseForm.companyUserName =
                res.result.companyLicense.companyUserName;

              this.companyLicenseForm.certNo = res.result.companyLicense.certNo;
              this.companyLicenseForm.companyPhone =
                res.result.companyLicense.companyPhone;

              this.companyLicenseForm.street = res.result.companyLicense.street;
              this.companyLicenseForm.bankName =
                res.result.companyLicense.bankName;

              this.companyLicenseForm.bankCode =
                res.result.companyLicense.bankCode;

              this.companyLicenseForm.type = res.result.companyLicense.type;
              this.companyLicenseForm.capital =
                res.result.companyLicense.capital;

              this.companyLicenseForm.business =
                res.result.companyLicense.business;

              this.companyLicenseForm.startDate =
                res.result.companyLicense.startDate;

              this.companyLicenseForm.endDate =
                res.result.companyLicense.endDate;

              this.companyLicenseForm.companyPhone =
                res.result.companyLicense.companyPhone;
              //联系人
              this.companyLicenseForm2.contactPhone =
                res.result.contactsIdCard.contactPhone;

              this.companyLicenseForm2.contactNum =
                res.result.contactsIdCard.num;

              this.companyLicenseForm2.contactName =
                res.result.contactsIdCard.name;

              this.companyLicenseForm.contactAddress =
                res.result.contactsIdCard.address;

              this.companyLicenseForm.contactBirth =
                res.result.contactsIdCard.birth;

              this.companyLicenseForm.contactSex =
                res.result.contactsIdCard.sex;

              this.companyLicenseForm.contactNationality =
                res.result.contactsIdCard.nationality;

              this.companyLicenseForm.contactStartDate =
                res.result.contactsIdCard.startDate;

              this.companyLicenseForm2.contactEndDate =
                res.result.contactsIdCard.endDate;

              this.companyLicenseForm.contactIssue =
                res.result.contactsIdCard.issue;

              // // 营业执照
              if (res.result.companyLicense.companyLicenseFileId != null) {
                this.companyLicenseForm.companyLicenseFileId =
                  res.result.companyLicense.companyLicenseFileId;
                this.companyPicFileUrl = this.imgUrl(
                  res.result.companyLicense.companyLicenseFileId
                );
              }
              //联系人信息 身份证正面
              if (res.result.contactsIdCard.idCardFontPicFileId != null) {
                this.companyLicenseForm.contactIdCardFontPicFileId =
                  res.result.contactsIdCard.idCardFontPicFileId;

                this.enterpriseIdCardFontPicFileUrl = this.imgUrl(
                  res.result.contactsIdCard.idCardFontPicFileId
                );
              }
              //联系人信息 身份证反面
              if (res.result.contactsIdCard.idCardBackPicFileId != null) {
                this.companyLicenseForm.contactIdCardBackPicFileId =
                  res.result.contactsIdCard.idCardBackPicFileId;

                this.enterprIseidCardBackPicFileUrl = this.imgUrl(
                  res.result.contactsIdCard.idCardBackPicFileId
                );
              }
            }
          } else {
            this.$Message.error(res.message);
          }
        }
      );
    },
    // 签约的确定按钮
    SignContract() {
      if (this.ContractCarriage.length == 0) {
        return this.$Message.warning("请上传货物运输合同");
      } else if (this.CorporateCard.length == 0) {
        return this.$Message.warning("请上传法人身份证");
      }
      this.SignContractbtn = true;
      let param = new FormData(); // 创建form对象
      param.append("contract", this.ContractCarriage); // 上传运输合同
      param.append("idNum", this.UploadHandler); // 法人身份证

      if (this.UploadLegalLersonIdCard.key != "empty") {
        param.append("authorization", this.UploadLegalLersonIdCard); // 经办人授权协议
      } else {
        param.append("authorization", ""); // 经办人授权协议
      }

      param.append("companyUserId	", this.OwnerId); // 货主id
      offlineContract(param).then((res) => {
        this.SignContractbtn = false;
        if (res.code == 200) {
          this.modalNotSigned = false;
          this.getDataList();
          this.$Message.info("签约成功");
        } else {
          this.$Message.error(res.message);
        }
      });
    },

    // 签约的保存按钮
    SaveSignContract() {
      if (this.ContractCarriage.length == 0) {
        return this.$Message.warning("请上传货物运输合同");
      }
      this.preservation = true;
      let param = new FormData(); // 创建form对象
      param.append("contract", this.ContractCarriage); // 上传运输合同
      param.append("companyUserId	", this.OwnerId); // 货主id
      signAontract(param).then((res) => {
        this.preservation = false;
        if (res.code == 200) {
          this.modalNotSigned = false;
          this.getDataList();
          this.$Message.info("保存成功");
        } else {
          this.$Message.error(res.message);
        }
      });
    },

    // 点击禁用
    frozen(v) {
      this.$Modal.confirm({
        title: "确认禁用",
        content: "您确认禁用 " + v.companyName + " 用户吗？",
        loading: true,
        onOk: () => {
          disableUser(v.userId).then((res) => {
            this.$Modal.remove();
            if (res.success) {
              this.$Message.success("操作成功");
              this.getDataList();
            } else {
              this.$Message.error(res.message);
            }
          });
        },
      });
    },
    //启用
    Enable(v) {
      this.$Modal.confirm({
        title: "确认启用",
        content: "您确认要启用 " + v.companyName + " ?",
        loading: true,
        onOk: () => {
          enableUser(v.userId).then((res) => {
            this.$Modal.remove();
            if (res.success) {
              this.$Message.success("操作成功");
              this.getDataList();
            } else {
              this.$Message.error(res.message);
            }
          });
        },
      });
    },

    // // // v// // // // // // // // // // // // // // // // //
    //身份证正面进度条 个人认证
    cardFontProcess(event, file, fileList) {
      this.progressAll(event, 1);
    },
    //身份证反面进度条 个人认证
    CardBackPro(event, file, fileList) {
      this.progressAll(event, 2);
    },
    // 营业执照 企业信息
    BusinessLicen(event, file, fileList) {
      this.progressAll(event, 3);
    },

    // 身份证正面 联系人信息
    enterprIseidCard(event, file, fileList) {
      this.progressAll(event, 4);
    },
    // 身份证反面 联系人信息
    enterprIseidCardf(event, file, fileList) {
      this.progressAll(event, 5);
    },

    // 身份证正面 法人信息
    corporateIseidCard(event, file, fileList) {
      this.progressAll(event, 6);
    },
    // 身份证反面 法人信息
    corporateIseidCardf(event, file, fileList) {
      this.progressAll(event, 7);
    },

    // 授权协议书
    AuthorizationAgreement(event, file, fileList) {
      this.progressAll(event, 8);
    },
    // 手持身份证联系人
    handHeldPro(event, file, fileList) {
      this.progressAll(event, 9);
    },
    // 手持身份证法人信息
    handHeldCardBackPro(event, file, fileList) {
      this.progressAll(event, 10);
    },
    // 手持身份证个人认证
    scardBackPro(event, file, fileList) {
      this.progressAll(event, 11);
    },
    // 身份证反面
    CardBackPross(event, file, fileList) {
      this.progressAll(event, 12);
    },
    setCurrentValue(value) {
      if (value === this.goodsVisible) {
        return;
      }
      this.title = "详细信息";
      this.maxHeight = "100%";
      // 清空数据
      this.$refs.form.resetFields();
      if (this.type == "0" || this.type == "1") {
        // 回显数据处理
        this.form = this.data;
      } else {
        // 添加
        delete this.form.id;
      }
      this.goodsVisible = value;
    },

    // 营业执照
    handleSuccess(res, file, fileList) {
      if (res.code == 500) {
        this.$Message.error(res.message);
        return;
      } else if (res.code == 200) {
        this.$Message.success("上传成功");
        this.form = { ...this.form, ...res.result };
        // this.companyLicenseForm = res.result;
        this.companyLicenseForm.companyName = res.result.companyName;
        this.companyLicenseForm.companyUserName = res.result.companyUserName;
        this.companyLicenseForm.certNo = res.result.certNo;
        this.companyLicenseForm.companyPhone = res.result.companyPhone;
        this.companyLicenseForm.street = res.result.street;
        this.companyLicenseForm.bankName = res.result.bankName;
        this.companyLicenseForm.bankCode = res.result.bankCode;
        this.companyLicenseForm.type = res.result.type;
        this.companyLicenseForm.capital = res.result.capital;
        this.companyLicenseForm.business = res.result.business;
        this.companyLicenseForm.startDate = res.result.startDate;
        this.companyLicenseForm.endDate = res.result.endDate;
        this.companyLicenseForm.companyLicenseFileId = res.result.filepath;
        if (this.companyLicenseForm.companyLicenseFileId != null) {
          this.companyPicFileUrl = this.$baseUrl + res.result.filepath;
        }
      }
    },
    // 联系人信息身份证正面
    enterpriseID(res, file, fileList) {
      if (res.code == 500) {
        this.$Message.error(res.message);
        return;
      } else if (res.code == 200) {
        this.$Message.success("上传成功");
        // this.form = { ...this.form, ...res.result };
        this.companyLicenseForm2.contactName = res.result.name;
        this.companyLicenseForm2.contactNum = res.result.num;
        this.companyLicenseForm.contactAddress = res.result.address;
        this.companyLicenseForm.contactNationality = res.result.nationality;
        this.companyLicenseForm.contactSex = res.result.sex;
        this.companyLicenseForm.contactBirth = res.result.birth;
        this.companyLicenseForm.contactIdCardFontPicFileId =
          res.result.filepath;
        if (this.companyLicenseForm.contactIdCardFontPicFileId != null) {
          this.enterpriseIdCardFontPicFileUrl =
            this.$baseUrl + res.result.filepath;
        }
      }
    },
    // 联系人信息身份证反面
    reverseIDCard(res, file, fileList) {
      if (res.code == 500) {
        this.$Message.error(res.message);
        return;
      } else if (res.code == 200) {
        this.$Message.success("上传成功");
        this.form = { ...this.form, ...res.result };
        this.companyLicenseForm.contactStartDate = res.result.startDate;
      }
      //判断长期+99年
      if (res.result.endDate == "长期") {
        let dateNew = Number(res.result.startDate) + Number(990000);
        this.companyLicenseForm2.contactEndDate = dateNew + "";
      } else {
        this.companyLicenseForm2.contactEndDate = res.result.endDate;
      }
      this.companyLicenseForm.contactIssue = res.result.issue;
      this.companyLicenseForm.contactIdCardBackPicFileId = res.result.filepath;

      if (this.companyLicenseForm.contactIdCardBackPicFileId != null) {
        this.enterprIseidCardBackPicFileUrl =
          this.$baseUrl + res.result.filepath;
      }
    },

    // 查看图片
    showPic(v) {
      let image = new Image();
      image.src = v;
      let viewer = new Viewer(image, {
        hidden: function () {
          viewer.destroy();
        },
      });
      viewer.show();
    },
    // 进度条
    progressAll(data, num) {
      if (num == 1) {
        //身份证正面进度条
        this.progressFlagnum = true; // 显示进度条
      } else if (num == 2) {
        //身份证反面进度条
        this.progressCardBack = true; // 显示进度条
      } else if (num == 3) {
        this.progressBusinessLicen = true;
      } else if (num == 4) {
        this.progressFront = true;
      } else if (num == 5) {
        this.progressReverse = true;
      } else if (num == 6) {
        this.corporateFront = true;
      } else if (num == 7) {
        this.corporateReverse = true;
      } else if (num == 8) {
        this.progressAgreement = true;
      } else if (num == 9) {
        this.handHeldProgress = true;
      } else if (num == 10) {
        this.handHeldCorporate = true;
      } else if (num == 11) {
        this.personalIDCard = true;
      } else if (num == 12) {
        this.personalIDCardard = true;
      }

      var CardBack = setTimeout(() => {
        this.load = parseInt(data.percent); // 动态获取文件上传进度
      }, 500); // 一秒后关闭进度条
      setTimeout(() => {
        if (this.load >= 100) {
          this.load = 100;
          setTimeout(() => {
            if (num == 1) {
              this.progressFlagnum = false; // 显示进度条
            } else if (num == 2) {
              this.progressCardBack = false; // 显示进度条
            } else if (num == 3) {
              this.progressBusinessLicen = false;
            } else if (num == 4) {
              this.progressFront = false;
            } else if (num == 5) {
              this.progressReverse = false;
            } else if (num == 6) {
              this.corporateFront = false;
            } else if (num == 7) {
              this.corporateReverse = false;
            } else if (num == 8) {
              this.progressAgreement = false;
            } else if (num == 9) {
              this.handHeldProgress = false;
            } else if (num == 10) {
              this.handHeldCorporate = false;
            } else if (num == 11) {
              this.personalIDCard = false;
            } else if (num == 12) {
              this.personalIDCardard = false;
            }
          }, 1000); // 一秒后关闭进度条
          clearTimeout(CardBack);
        }
      }, 501);
    },
    //压缩图片
    beforeUpload(file) {
      return new Promise((resolve, reject) => {
        // console.log("压缩前", file); // 压缩到400KB,大于400KB的图片都会进行压缩，小于则不会
        imageConversion.compressAccurately(file, 100).then((res) => {
          res = new File([res], file.name, {
            type: res.type,
            lastModified: Date.now(),
          });
          resolve(res);
        });
      });
    },
    // 企业认证保存
    submitCompanyLicenseInfo() {
      let form = false;
      let form2 = false;
      this.$refs.companyLicenseForm.validate((valid) => {
        if (valid) {
          form = true;
        } else {
          form = false;

          return this.$Message.error("企业认证资料不完整");
        }
      });
      if (this.companyPicFileUrl == "") {
        return this.$Message.error("请上传营业执照");
      }
      this.$refs.companyLicenseForm2.validate((valid) => {
        if (valid) {
          form2 = true;
          this.companyLicenseForm.contactName =
            this.companyLicenseForm2.contactName;
          this.companyLicenseForm.contactPhone =
            this.companyLicenseForm2.contactPhone;
          this.companyLicenseForm.contactEndDate =
            this.companyLicenseForm2.contactEndDate;
          this.companyLicenseForm.contactNum =
            this.companyLicenseForm2.contactNum;
        } else {
          form2 = false;
          return this.$Message.error("联系人信息资料不完整");
        }
      });
      if (!this.enterpriseIdCardFontPicFileUrl) {
        return this.$Message.error("请上传联系人身份证正面");
      }
      if (!this.enterprIseidCardBackPicFileUrl) {
        return this.$Message.error("请上传联系人身份证反面");
      }

      if (!this.companyLicenseForm.companyUserName) {
        return this.$Message.error("请输入法定代表人");
      }

      if (form && form2) {
        this.$refs.companyLicenseForm.validate((valid) => {
          if (valid) {
            this.loadinLicenseInfo = true;

            this.companyLicenseForms.endDate = this.timeText(
              this.companyLicenseForms.endDate
            );
            this.companyLicenseForms.contactStartDate = this.timeText(
              this.companyLicenseForms.contactStartDate
            );
            this.companyLicenseForms.contactEndDate = this.timeText(
              this.companyLicenseForms.contactEndDate
            );
            this.companyLicenseForms.legalpersonEndDate = this.timeText(
              this.companyLicenseForms.legalpersonEndDate
            );

            this.companyLicenseForm.userId = this.companyLicenseForms.userId;
            for (let item in this.companyLicenseForm) {
              if (
                this.companyLicenseForm[item] == "" ||
                this.companyLicenseForm[item] == null ||
                this.companyLicenseForm[item] == ""
              ) {
                delete this.companyLicenseForm[item];
              }
            }
            saveCompanyLicenseInfo(this.companyLicenseForm).then((res) => {
              this.loadinLicenseInfo = false;
              if (res.success) {
                this.$Message.success("企业认证信息提交成功");
                this.getDataList();
              } else {
                this.$Message.error(res.message);
              }
            });
          }
        });
      }
    },
    // 时间去横杠
    timeText(val) {
      let text = "";
      if (val) {
        let arr = val.split("");
        arr.forEach((item) => {
          if (item == "-") {
          } else {
            text += item;
          }
        });
      }
      return text;
    },
    // 切换
    cargoTabs(val) {
      if (val == "realNameAuthentication") {
        this.spinShow = true;
        this.nameAuthentication();
        setInterval(() => {
          this.spinShow = false;
        }, 1000);
      } else {
        this.spinShow = true;
        this.enterpriseCertification();
        setInterval(() => {
          this.spinShow = false;
        }, 1000);
      }
    },
    authenticationTabs() {},
    enDrawer(val) {
      this.goodsVisible = true;
      this.$Modal.confirm({
        title: "确认关闭",
        content: "确认关闭？",
        loading: true,
        onOk: () => {
          this.goodsVisible = false;
        },
      });
    },
  },
  mounted() {
    this.init();
    if (localStorage.getItem("jurisdictionCargo") == "ROLE_CargOwner") {
      this.columns = this.columns.filter((col) => col.key !== "action");
    } else {
      this.columns = this.columns;
    }
  },
};
</script>
<style lang="less">
// 建议引入通用样式 具体路径自行修改 可删除下面样式代码
// @import "../../../styles/table-common.less";
.search {
  .operation {
    margin-bottom: 2vh;
  }
  .select-count {
    font-weight: 600;
    color: #40a9ff;
  }
  .select-clear {
    margin-left: 10px;
  }
  .page {
    margin-top: 2vh;
  }
}
.SignedUpload {
  display: flex;
  height: 58px;
  width: 242px;
  margin-left: 10px;
}
.ContractName {
  width: 220px;
  margin-top: -10px;
  margin-left: 31px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 13px;
  margin-bottom: 10px;
  border: 1px dashed #eee;
  padding: 0 5px;
}
.SigneContractC {
  height: 70px;
}

.agreement {
  position: relative;
  top: -38px;
  left: -7px;
  font-size: 14px;
  margin-left: 63px;
  margin-right: 10px;
}
.CorporateIDCard {
  position: relative;
  top: -38px;
  left: -7px;
  font-size: 14px;
  margin-right: 0px;
  margin-left: 18px;
}
// 图片
.demo-upload-list {
  display: inline-block;
  width: 60px;
  height: 60px;
  text-align: center;
  line-height: 60px;
  border: 1px solid transparent;
  border-radius: 4px;
  overflow: hidden;
  background: #fff;
  position: relative;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
  margin-right: 4px;
}
.demo-upload-list img {
  width: 60px;
  height: 60px;
}
.demo-upload-list-cover {
  display: none;
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.6);
}
.demo-upload-list:hover .demo-upload-list-cover {
  display: block;
}
.demo-upload-list-cover i {
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  margin: 0 2px;
}
.Signed {
  margin-left: 22px;
  width: 300px;
}
.ListItemcss {
  height: 200px;
  overflow: auto;
  .ivu-list-header {
    font-weight: 700;
    font-size: 15px;
  }
}

.demo-upload-list-company {
  display: inline-block;
  width: 150px;
  height: 90px;
  text-align: center;
  line-height: 60px;
  border: 1px solid transparent;
  border-radius: 4px;
  overflow: hidden;
  background: #fff;
  position: relative;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
  margin-right: 4px;
}
.demo-upload-list-company img {
  width: 148px !important;
  height: 88.2px !important;
}
.demo-upload-list-company-cover {
  display: none;
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.6);
}
.demo-upload-list-company:hover .demo-upload-list-company-cover {
  display: block;
}
.demo-upload-list-company-cover i {
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  margin: 0 2px;
  line-height: 90px;
}

//
.check {
  &::before {
    content: "*";
    display: inline-block;
    margin-right: 2px;
    line-height: 1;
    font-family: SimSun;
    font-size: 14px;
    color: #ed4014;
  }
}
.checkdrag {
  &::before {
    content: "*";
    display: inline-block;
    margin-right: 2px;
    line-height: 1;
    font-family: SimSun;
    font-size: 14px;
    color: #ed4014;
    width: 5px;
    margin-left: 5px;
  }
}

.demo-uploadcss-compny {
  margin-top: -13px;
  width: 150px;
  height: 5px;
}
.adoptSubmitId {
  display: flex;
  justify-content: flex-end;
  margin-top: 347px;
}
.Cardokbtn-comy-comy {
  position: relative;
  bottom: 10px;
  left: 0;
  text-align: right;
}
.okbtn-comy {
  z-index: 99999;
  width: 100%;
  margin-top: -15px;
  // background-color: #f5f5f5;
  // border: 1px solid #cdcdcd;
  // height: 70px;
  // line-height: 70px;
}
.demo-drawer-footers-company {
  width: 100%;
  position: absolute;
  bottom: 0;
  left: 0;
  padding: 10px 16px;
  text-align: right;
  background-color: #f5f5f5;
  border: 1px solid #cdcdcd;
}
.check_font_message {
  font-size: 10px;
  color: #ed4014;
  font-weight: 600;
}
.check_font {
  font-size: 10px;
  font-weight: 600;
}
.Upload-border {
  .ivu-upload-drag {
    border: 0px !important;
  }
}
.more-css {
  .ivu-dropdown-item {
    text-align: left;
  }
}
</style>
